Trust, but Verify: Two-Phase Typing for Dynamic Languages

نویسندگان

  • Panagiotis Vekris
  • Benjamin Cosman
  • Ranjit Jhala
چکیده

A key challenge when statically typing so-called dynamic languages is the ubiquity of value-based overloading, where a given function can dynamically reflect upon and behave according to the types of its arguments. Thus, to establish basic types, the analysis must reason precisely about values, but in the presence of higher-order functions and polymorphism, this reasoning itself can require basic types. In this paper we address this chicken-and-egg problem by introducing the framework of two-phased typing. The first “trust” phase performs classical, i.e. flow-, pathand value-insensitive type checking to assign basic types to various program expressions. When the check inevitably runs into “errors” due to value-insensitivity, it wraps problematic expressions with DEAD-casts, which explicate the trust obligations that must be discharged by the second phase. The second phase uses refinement typing, a flowand path-sensitive analysis, that decorates the first phase’s types with logical predicates to track value relationships and thereby verify the casts and establish other correctness properties for dynamically typed languages. 1998 ACM Subject Classification D.3.3 [Programming Languages]: Language Constructs and Features – Constraints, Polymorhpism; F.3.1 [Logics and Meanings of Programs]: Specifying and Verifying and Reasoning about Programs – Assertions, Preand post-conditions; F.3.3 [Logics and Meanings of Programs]: Studies of Program Constructs – Type structure

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Design and Implementation of Gnarly, a Hybrid-Typed Programming Language

Numerous approaches to the problem of determining the correctness of computer programs have been proposed and implemented, such as dynamic and static type checking. Static typing enables earlier error checking and more e cient execution in many programs, while dynamic type systems allow for greater expressiveness and exibility. This paper presents a type system, hybrid typing, and a programming...

متن کامل

Type Systems of Scripting Languages

Type systems play an important role in the design of programming languages, they prevent programs from having non-correct behavior. Typically, type systems are expressed in two ways, type-checking and type inference. The type information presented on local variables and method arguments makes the difference in choosing one technique rather than the other. Type checking is a derivation type infe...

متن کامل

Including both static and dynamic typing in the same programming language

Dynamic languages are becoming increasingly popular for different software development scenarios such as Web engineering, rapid prototyping, or the construction of applications that require runtime adaptiveness. These languages are built on the idea of supporting reasoning about (and customizing) program structure, behaviour and environment at runtime. The dynamism offered by dynamic languages ...

متن کامل

Attaining multiple dispatch in widespread object-oriented languages

Multiple dispatch allows determining the actual method to be executed, depending on the dynamic types of its arguments. Although some programming languages provide multiple dispatch, most widespread object-oriented languages lack this feature. Therefore, different implementation techniques are commonly used to obtain multiple dispatch in these languages. We evaluate the existing approaches, pre...

متن کامل

Union and intersection types to support both dynamic and static typing

Although static typing provides undeniable benefits for the development of applications, dynamically typed languages have become increasingly popular for specific scenarios. Since each approach offers different benefits, the StaDyn programming language has been designed to support both dynamic and static typing. This paper describes the minimal core of the StaDyn programming language. Its type ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2015